package com.wfm.queue;

import lombok.SneakyThrows;

import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.springframework.stereotype.Service;

@Service
public class DataQueue {

    private BlockingQueue<String> queue = new LinkedBlockingQueue<>();

    public void add(String url) {
        queue.add(url);
    }

    public void add(List<String> url) {
        queue.addAll(url);
    }

    @SneakyThrows
    public String get() {
        return queue.poll(500, TimeUnit.MILLISECONDS);
    }

    public int size() {
        return queue.size();
    }

}
